﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuickRunnable.Quick
{
    // I need some way to bridge from this 'property' 'schema' land back into the real world.
    // One way or another, I need to take an instance of something a PropertyDeclaration or some shit
    // and get a Key out of it. The "Expression" from before is bad, why exactly?
    // 
    // 


    public class PropertyDeclaration {
        private String m_Type;
        private String m_PropertyName;

        public PropertyDeclaration( String type, String property_name ) {
            m_Type = type;
            m_PropertyName = property_name;
        }

        public String Type { get { return m_Type; } }
        public String PropertyName { get { return m_PropertyName; } }

        // I don't want to fetch data from reflection, but realistically I'm unsure of how to do it otherwise.
        // I don't want to use a dynamic type. I don't want to use a dictionary of objects.
    }

    // this type of equality declaration is sort of an alias
    // instead of being collection based, any number of equality declarations can be dumped into a list.
    public class EqualityDeclaration : PropertyDeclaration{
    
        private readonly PropertyDeclaration m_Underlying;
        
        public EqualityDeclaration( String type,
                                    String property_name,
                                    PropertyDeclaration underlying ) 
            : base( type, property_name ) {
            m_Underlying = underlying;
        }

        public PropertyDeclaration Underlying { get { return m_Underlying; } }
    }

    

    public class TypeRegistry {

        public PropertyDeclaration Register( String type, String property_name ){}
        public EqualityDeclaration Register( String type,
                                             String property_name,
                                             PropertyDeclaration underlying ) {}
        public PropertyDeclaration RegisterKey( String type, String property_name ){}

        public Schema GetSchema( String type ){}
    }




    public class Schema {
        private readonly String m_Name;
        private readonly IEnumerable< PropertyDeclaration > m_Properties;
        private readonly IEnumerable< PropertyDeclaration > m_Keys;

        public Schema( String name, IEnumerable< PropertyDeclaration > properties, IEnumerable< PropertyDeclaration > keys ) {
            m_Name = name;
            m_Properties = properties;
            m_Keys = keys;
        }

        public string Name { get { return m_Name; } }
        public IEnumerable< PropertyDeclaration > Properties { get { return m_Properties; } }
        public IEnumerable< PropertyDeclaration > Keys { get { return m_Keys; } }
    }
}
